﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace SmartCollection
{
    public class ClassBase
    {
    }
    public class CategoryNewsUrl
    {
        public string Link { get; set; }
        public int ParentId { get; set; }
        public int Id { get; set; }

    }
    public class PageUrlNews
    {
        public string Img { get; set; }
        public string Title { get; set; }
        public string ShortDescription { get; set; }
        public string Url { get; set; }
        public string ParentId { get; set; }
        public string CategoryNewsId { get; set; }
    }

    public class ProductBase
    {
        public string Name { get; set; }
        public string Link { get; set; }
        public string Price { get; set; }
        public string Code { get; set; }
        public string FullDescription { get; set; }
        public string ShortDescription { get; set; }
        public IList<Img> _Imgs { get; set; }
        //public ProductBase()
        //{
        //    _Imgs = new List<Img>();
        //}
    }
    public class Img
    {
        public string _Name { get; set; }
        public string _Link { get; set; }
    }

    public static class Extensions
    {
        public static string ToCutString(this object obj)
        {
            String s = obj.ToString();
            if (s.Contains("\n") || s.Contains("\t") )
            {
                s.Replace("\n", "");
                s.Replace("\t", "");
               
                
            }
            if (s.Contains('\"'))
            {
                string[] a = s.Split('\"');
                s = a[1].ToString();
            }
            if(s.IndexOf("-")>=0)
            {
                s.Remove(s.IndexOf("-"),1);
            }
            return s.Trim().Replace("-", " ").Replace("&quot;","");
        }
        // convert co dau sang khong dau
        public static string convertToUnSign3(this object obj)
        {
            Regex regex = new Regex("\\p{IsCombiningDiacriticalMarks}+");
            string s = obj.ToString();
            string temp = s.Normalize(NormalizationForm.FormD);

            return regex.Replace(temp, String.Empty).Replace('\u0111', 'd').Replace('\u0110', 'D').Replace(" ","-");
        
        }
        // check chuoi la so 
        public static bool IsNumber(this object obj)
        {
            string pValue = obj.ToString();
            foreach (Char c in pValue)
            {
                if (!Char.IsDigit(c))
                    return false;
            }
            return true;
        }

    }
}
